<?php

class AppController extends Controller {

    var $helpers = array('Html', 'Ajax', 'Javascript', 'Session', 'Facebook.Facebook');
    var $components = array('Auth', 'Facebook.Connect', 'RequestHandler', 'Session');

    function beforeFilter() {
        parent::beforeFilter();
        $this->set('facebookUser', $this->Connect->user());
        $this->Auth->autoRedirect = false;
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'profile'); 
        $this->Auth->fields = array('username' => 'email', 'password' => 'password');
        $this->Auth->loginError = "Invalid Username or Password";
        $this->Auth->authError = "You are not authorize to access that location.";
    }
    function afterFacebookLogin(){
        //$facebookUser=$this->Connect->user();        
        $this->redirect(array('controller' => 'users', 'action' => 'profile'));
    }

}
